package com.dyna.foundation.feign;

import com.dyna.constants.AppConstant;
import com.dyna.core.config.FeignConfig;
import com.dyna.domain.resp.R;
import com.dyna.foundation.domain.entity.SysDictData;
import com.dyna.foundation.failback.FoundationDictFailBack;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

/**
 * @author zhoucaiwang
 * name 指定要调用的服务名称
 */

@Component
@FeignClient(name = AppConstant.APPLICATION_FOUNDATION_NAME,
            value = AppConstant.APPLICATION_FOUNDATION_NAME,
            fallback = FoundationDictFailBack.class,
            configuration = FeignConfig.class)
public interface FoundationDictApi {

    String DICT_PREFIX = "/sys-dict";

    @ApiOperation(value = "批量查询字典数据")
    @PostMapping(DICT_PREFIX + "/getBatchSysDictList")
    R<Map<String, List<SysDictData>>> getBatchSysDictList(@RequestBody List<String> dictTypeList);

    @ApiOperation(value = "根据字典类型查询字典数据")
    @GetMapping(DICT_PREFIX + "/getSysDictDataMapByType")
    R<Map<Integer, String>> getSysDictDataMapByType(@RequestParam(value = "dictType",required = true) String dictType);

}
